<template>
  <div class="down">
    <div class="template-2 template-wrap">
      <div class="t-bg-2"></div>
      <div class="container">
        <div class="content">
          <div class="template-common">
            <div class="t-icon">
              <img src="~/@/assets/images/avatar.jpg" class="img-responsive">
            </div>
            <div class="t-name">
              <div class="tit">刷卡宝</div>
              <div class="info">
              <span v-show="!win">适用于苹果手机</span>
              <span v-show="win">适用于安卓手机</span>
              </div>
            </div>
            <div>
              <x-button v-show="!win" class="custom-primary" link="http://www.kangliankeji.com/shuakabao.mobileconfig" type="primary"><img src="~/@/assets/images/down.png" style="width: .5rem;margin-right:.1rem;">下载安装</x-button>
              <a href="http://www.kangliankeji.com/skb.apk?name=skb"><x-button v-show="win" class="custom-primary" type="primary"><img src="~/@/assets/images/down.png" style="width: .5rem;margin-right:.1rem;">下载安装</x-button>
              </a>
            </div>
            <span class="info">服务热线：400-639-8996</span>
            <div class="android-img" v-show="!win">
              <span style="font-size: 18px;font-weight: bold;padding-bottom: 5px;display:block;">苹果流程</span>
              <ul class="ios-list">
                <li>1. 点击 <span style="color: red;">下载安装</span></li>
                <li>2. 提示尝试下载配置描述文件点击 <span style="color: red;">允许</span></li>
                <li><img src="~/@/assets/images/lc1.jpg" style="width: 100%;"></li>
                <li>3. 提示已下载配置描述文件点击 <span style="color: red;">关闭</span></li>
                <li><img src="~/@/assets/images/lc2.jpg" style="width: 100%;"></li>
                <li>4. 进入<span style="font-weight: bold;">苹果通用设置</span>点击 <span style="color: red;">已下载描述文件</span></li>
                <li><img src="~/@/assets/images/lc3.jpg" style="width: 100%;"></li>
                <li>5. 点击右上角 <span style="color: red;">安装</span> 输入密码</li>
                <li><img src="~/@/assets/images/lc4.jpg" style="width: 100%;"></li>
                <li>6. 弹出警告继续点击 <span style="color: red;">安装</span>下面弹出窗口点击安装</li>
                <li><img src="~/@/assets/images/lc5.jpg" style="width: 100%;"></li>
                <li>7. 点击右上角安装完成</li>
                <li><img src="~/@/assets/images/lc7.jpg" style="width: 100%;"></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div id="weixin_ios" v-show="isWexin">
        <div class="click_opacity"></div>
        <div class="to_btn">
          <span class="span1">
            <img src="~/@/assets/images/click_btn.png">
          </span>
          <span class="span2">
            <em>1</em> 点击右上角
            <img src="~/@/assets/images/menu.png">
            打开菜单
          </span>
          <span v-show="!win" class="span2">
            <em>2</em> 选择
            <img src="~/@/assets/images/safari.png">
            用Safari打开下载
          </span>
          <span v-show="win" class="span2">
            <em>2</em> 选择
            <img src="~/@/assets/images/safari.png">
            用浏览器打开
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { XButton } from 'vux'
export default {
  name: 'down',
  components: {
    XButton
  },
  data () {
    return {
      isWexin: false,
      win: true
    }
  },
  methods: {
    getInfo () {
      var ua = navigator.userAgent.toLowerCase()
      // let isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
      // Ios终端
      // let isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
      var isWeixin = ua.indexOf('micromessenger') !== -1
      if (isWeixin) {
        this.isWexin = true
      } else {
        this.isWexin = false
      }
      if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
        // ios系统输出
        this.win = false
      } else if (/(Android)/i.test(navigator.userAgent)) {
        // android系统输出
        this.win = true
      }
    }
  },
  mounted () {
    this.getInfo()
  }
}
</script>

<style lang="less" scoped>
.ios-list li {
  text-align: left;
  padding: 5px 0;
}
.down {
  background: #fff;
  width: 100%;
  min-height: 100vh;
  .android-img {
    text-align: center;
    margin-top: 10px;
    img {
      width: 150px;
    }
  }
  .custom-primary {
    border-radius: 5rem;
    background: #2e93ef;
    width: 50%;
    margin-top: .5rem;
    margin-bottom: .1rem;
  }
  .template-2 .t-bg-2 {
    background: #2e93ef;
    height: 130px;
  }
  .container {
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
    .content {
      margin-top: -80px;
      padding-top: 40px;
      padding-bottom: 40px;
      .t-icon {
        width: 3.5rem;
        height: 3.5rem;
        background-color: #fff;
        box-shadow: 0 0 10px rgba(0,0,0,.1);
        border-radius: 20px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        .img-responsive {
          border-radius: 10px;
          width: 120px;
          height: 120px;
          border: 1px solid #e5e5e5;
          margin: 0 auto;
          max-width: 100%;
          display: block;
        }
      }
      .t-name {
        .tit {
          text-align: center;
          font-size: .4rem;
          font-weight: 600;
          margin-top: .5rem;
          margin-bottom: .3rem;
        }
      }
      .info {
        color: #999;
        display: block;
        text-align: center;
        line-height: 150%;
      }
    }
  }
  .click_opacity {
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0.6;
    position: fixed;
    z-index: 10000;
    top: 0px;
  }
  .to_btn {
    position: fixed;
    top: 10px;
    right: 10px;
    text-align: right;
    z-index: 10001;
    font-family: "微软雅黑";
    color: #fff;
    img {
      width: 20%;
      height: auto;
      display: inline-block;
    }
    span {
      display: block;
      float: right;
      &.span1 {
        font-size: 1.6rem;
        color: #fff;
        margin-top: .1rem;
      }
      &.span2 {
        display: inline-block;
        line-height: 36px;
        width: 80%;
        margin-bottom: 12px;
        text-align: left;
        font-size: 16px;
        img {
          display: inline-block;
          width: 30px;
          height: 30px;
          margin: 0px 5px;
        }
        em {
          display: inline-block;
          width: 16px;
          height: 16px;
          background: #009dd9;
          color: #fff;
          font-size: 12px;
          text-align: center;
          line-height: 16px;
          border: 1px solid #fff;
          border-radius: 50%;
          margin-right: 3px;
        }
      }
    }
  }
}
</style>
